The Edit menu is separated into five sections. The two topmost sections are standards of MacOS. Section three is devoted to text editing and section four is devoted to scripts. In the last section you will find the "Preferences…" menu item.
Undo / Redo (and other titles) ( Z)
Undo reverses the latest editing action done in the active window. The actual title of this menu varies depending on the exact nature of the editing taking place in the active window. The various titles possible in this menu are listed below to illustrate the comprehensiveness of this particularly useful function.
• Undo Cut — Redo Cut
• Undo Style Change — Redo Style Change
• Undo Paste — Redo Paste
• Undo Typing — Redo Typing
• Undo Drag — Redo Drag
Note that "each window has its own undo". When you make a window active, you can undo the last action performed even if it was performed a long time ago - provided the changes have not been saved.
----------------------------
Cut ( X)
Removes the selection of the active window and places it on the Clipboard. Styled and colored text is supported, and this action is undoable. Smile performs a "smart cut" by removing the extra space when you cut a word or a group of words.
Copy ( C)
Copies the selection of the active window to the Clipboard. Styled and colored text is supported. Typically, using the "Paste" command follows using the "Copy" command.
Paste ( V)
Inserts contents of Clipboard at insertion point, deleting (replacing) anything that may be selected. Smile performs a "smart paste" by adding a space before the string that is pasted, if it recognizes you are pasting whole words. You will observe the same behavior with drag-and-drop. This function is provided by the WASTE text engine that Smile uses. About the WASTE text engine, see the credits.
Clear
Deletes the current selection. This action is undoable.
Select All ( A)
Selects the entire contents of the active window.
----------------------------
The next three items are related to the "Find" dialog box of Smile. These commands work the same with script windows and text windows.
Find ( F)
Opens (or brings to front if it is already opened) the "Find" dialog box. The contents of the search string field is automatically highlighted so you can directly type the search string.
Find again ( G)
Finds and selects (highlights) the next occurrence of the search string after the current selection in the active window.
The "Find" dialog box need not be open.
Find selection ( H)
Sets the search string to the text selected in the active window, and searches for the next occurrence of this string in this window. The "Find" dialog box need not be open.
You can then use "Find again" to find the next occurrences.
Compare ( K)
This function compares the texts of the two frontmost windows, starting (in each window) at the end of the current selection. The "Compare" function is not sensitive to differences in text style, font, or color.
When comparing all of the text of one window with all of the text of another window, be sure the insertion pointer is located at the beginning of the text in both windows before choosing "Compare".
When it find a difference, the "Compare" function highlights in each window the portion of text which it has found as being different. At this point, you may want to activate one of the windows, "Copy" ( C) the selected text, activate the other window and "Paste" ( V) it in the current selection.
Thus, if you press K again, it will jump to the next difference.
If no difference is found, the message "The files are identical to the end." will be presented in a dialog box.
----------------------------
Run script
This menu item is enabled exclusively when the active window is a script window. "Run script" will be grayed out (disabled) if a script window is not active.
Selecting "Run script" executes (runs) the entire script (all lines) of the active script window after successful compilation. Precisely, it launches the execution of the "run" (or unnamed) handler of the active script window. You can also use the small button with the "start" icon, in the bottom of the script window. The script is compiled before execution and execution takes place only after successfully compiling. Incorrect syntax will result in the display of a dialog box.
The result of the execution of the script, if any, is appended by default to the "Worksheet". If the "Worksheet" is not open, it will be automatically opened by Smile. It is also possible to redirect the result of the script to other output windows.
Check syntax
As with "Run script", "Check syntax" is used exclusively with script windows. This menu item will be grayed out if a script window is not active.
Selecting "Check syntax" will check the syntax of all lines of script of the active script window. This menu item performs the identical function as clicking the check-syntax button (checkmark icon ), at the bottom of the script window.
You can also check syntax by pressing the Enter key while the script window is active. The Enter key is in the numeric keypad on the desktop keyboards. (The Enter key is not the carriage return key ). If your keyboard has no Enter key, you can alternately press the combination ctrl-C.
Note : Pressing Enter key will always check the syntax and compile the script of the active script window. There are no exceptions. This is not true of the check-syntax button (checkmark icon ) or "Check syntax" menu item. These only check syntax and compile if the contents of the script window have been changed. This is an important point to remember if you declare a script property, and the script property is changed during the running of the script.
Use Enter key if you desire to reinitialize the value of the script property before rerunning the script.
A successful syntax check may result in some of the script text being presented in a different text style and changed in format, depending on preference settings (see "Preferences" dialog). An unsuccessful syntax check will result in a dialog box being presented. This dialog box may present information that you will find helpful in correcting the syntax.
Record
Starts the recording of user actions. While recording is active, the menu name will change to "Stop" and the Apple menu icon will flash between Apple and cassette symbols. While recording, user actions are monitored, and associated script lines are appended to the end of the active window (provided it is a text window or a script window). See Recording with Smile.
Applications that are "recordable" can be of much help while writing scripts. Smile and Finder are two of many applications offering the beneficial combination of being both recordable and scriptable.
----------------------------
Preferences
Opens the "Preferences" dialog.
Agents
In Smile, this menu can be used only on graphic windows.
• The clipboard commands on text and script windows can be scripted. Here are two examples.
----------------------------
tell window 2 to paste
----------------------------
tell window 2 to undo
----------------------------
• By default, the Undo command applies to the last elementary editing action. If you script a complex text editing operation, you can make it undoable by encapsulating it as in the example below.
----------------------------
set store undo of window 1 to true
-- do some changes and text editing
set store undo of window 1 to false
----------------------------
• The items of section two of the "Edit" menu (Cut, Copy, Paste, Delete, Select all) can be used with custom dialog items.
• When using the "Compare" function, you may want to use the "Copy to selection" button. This button can be found in the samples located in the "Advanced stuff" folder. Drop this button onto both windows. Use it to copy the selected text from the front window to the corresponding selection of the second window.
• The "Agent" menu lists all the agents of the active window. The agents of a text window are its buttons, if it has any (see buttons). The agents of graphic and movie windows can be of different types (agent groups, labels and buttons).
In graphic and movie windows, each agent can perform tasks automatically, triggered by certain events. This automatic behavior can be switched on / off. A checkmark before the name of an agent shows automatic behavior is active. Selecting an agent in the Agents menu toggles this behavior on / off.
• Selecting an agent in the Agents menu with the option key () down toggles the visibility of this agent. Use this menu to restore the visibility of an invisible agent.
• The button "Record" provided in the "Advanced stuff" folder allows to switch to a more complete recording. If you click this button (after installation in a text window) with the option key () down, the recording operates in a verbose mode. All calls will be displayed. In this verbose moe, you may need to click twice the "Stop" button to switch recording off. Save any open document before launching recording in the verbose mode.